home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tricks of the Mac Game Programming Gurus
/
TricksOfTheMacGameProgrammingGurus.iso
/
More Source
/
Libraries
/
SAT 2.3b4
/
Demo ƒ
/
myPlatform demo ƒ
/
myPlatform.p
< prev
next >
Wrap
Text File
|
1995-04-23
|
3KB
|
96 lines
{***************************}
{********* myPlatform **********}
{***************************}
{This demo is a hack I made, testing if we can use faceless sprites to make stationary}
{obstacles. That worked pretty nicely, so I went on and made some moving platforms too.}
{Take it for what it is: a test hack that suggests one way to make this kind of games.}
{There are many other ways. The controls can be improved a lot, but it is a start.}
program myPlatform;
uses
{$ifc UNDEFINED THINK_PASCAL}
Types, QuickDraw, Events, Windows, Dialogs, Fonts, DiskInit, TextEdit, Traps,{}
Memory, SegLoad, Scrap, ToolUtils, OSUtils, Menus, Resources, StandardFile,{}
GestaltEqu, Files, Errors,
{$endc}
SAT, sPlayerSprite, sPlatform, sMovPlatForm, sHMovPlatForm;
var
ignoreSp: SpritePtr;
l: Longint;
p: Point;
r: Rect;
thepat: SATPatHandle;
procedure DrawInfo;
var
r: Rect;
begin
SATSetPortBackScreen;
SetRect(r, 100, 50, 300, 100);
EraseRect(r);
FrameRect(r);
MoveTo(110, 70);
DrawString('SAT Platform demo');
MoveTo(110, 90);
DrawString('Move with "," "." and space');
SATBackChanged(r);
end;
begin
{Standard Inits are done by Think Pascal.}
{$IFC UNDEFINED THINK_PASCAL}
SATInitToolbox;
{$ENDC}
SATConfigure(true, kLayerSort, kBackwardCollision, 32);
SATInit(0, 0, 512, 322); {No PICTs}
{Use a background pattern (instead of PICTs - just to demo that too)}
SATSetPortBackScreen;
thepat := SATGetPat(128);
SATPenPat(thepat);
SetRect(r, 0, 0, gSAT.offsizeH, gSAT.offsizeV);
PaintRect(r);
CopyBits(gSAT.backScreen.port^.portBits, gSAT.offScreen.port^.portBits, gSAT.offScreen.port^.portrect, gSAT.offscreen.port^.portrect, srcCopy, nil);
{Draw the info text}
DrawInfo;
{Initialize all sprite units}
InitPlayerSprite;
InitPlatform;
InitMovPlatform;
InitHMovPlatform;
{Update the game window (gSAT.wind) once more, so the pattern and what we drawn in DrawInfo are shown.}
SATRedraw;
{Make the sprites.}
GetMouse(p);
ignoreSp := SATNewSprite(1, p.h, p.v, @SetupPlayerSprite);
ignoreSp := SATNewSprite(0, 50, 300, @SetupPlatform);
ignoreSp := SATNewSprite(0, 150, 200, @SetupPlatform);
ignoreSp := SATNewSprite(0, 250, 100, @SetupPlatform);
ignoreSp := SATNewSprite(0, 350, 50, @SetupPlatform);
ignoreSp := SATNewSprite(0, 350, 300, @SetupMovPlatform);
ignoreSp := SATNewSprite(0, 50, 200, @SetupMovPlatform);
ignoreSp := SATNewSprite(0, 200, 150, @SetupHMovPlatform);
HideCursor;
done := false;
repeat
l := TickCount;
SATRun(true); {Run one frame of animation.}
while l > TickCount - 2 do {Maximize speed to 30 fps}
;
until done or Button;
ShowCursor;
SATSetPortScreen; {To make sure the device is valid when exiting}
SATSoundShutUp; {Always make sure the sound channel is de-allocated!}
end.